<template>
  <div class="elm-edit">
    <elm-page-bb>
      <el-form ref="model" :model="model" size="small" label-width="80px">
        <elm-row>
          <el-form-item label="收款金额" prop="sk_amount" :rules="[{trigger: 'blur' ,validator: validateNumber}]">
            <el-input v-model="model.sk_amount">
              <template slot="append">
                <div style="width: 25px;text-align: center;">万元</div>
              </template>
            </el-input>
          </el-form-item>
          <el-form-item label="关联项目" prop="pj_id">
            <elm-select-input v-model="model.pj_id" url="/business/my/GetPjData" :readonly="false" :show-id="true">
            </elm-select-input>
          </el-form-item>
        </elm-row>
        <elm-row>
          <el-form-item label="关联订单" prop="order_id">
            <elm-select-input v-model="model.order_id" url="/business/my/GetOrderData" :readonly="false" :show-id="true">
            </elm-select-input>
          </el-form-item>
          <el-form-item label="关联合同" prop="contract_id">
            <elm-select-input v-model="model.contract_id" url="/business/my/GetContractData" :readonly="false" :show-id="true">
            </elm-select-input>
          </el-form-item>
        </elm-row>
        <elm-row>
          <el-form-item label="收款方式" prop="sk_type">
            <elm-code dict_type="bms_receipt_fs" v-model="model.sk_type"></elm-code>
          </el-form-item>
          <el-form-item label="收款账户" prop="sk_account">
            <el-input v-model="model.sk_account"></el-input>
          </el-form-item>
        </elm-row>
        <elm-row>
          <el-form-item label="跟进人" prop="sk_person">
            <elm-ei v-model="model.sk_person"></elm-ei>
          </el-form-item>
          <el-form-item label="收款时间" prop="sk_date">
            <el-date-picker v-model="model.sk_date" type="datetime" value-format="yyyy-MM-ddTHH:mm:ss"
                            style="width: 100%">
            </el-date-picker>
          </el-form-item>
        </elm-row>
        <elm-row>
          <el-form-item label="结算编号" prop="js_id">
            <elm-select-input v-model="model.js_id" url="/business/my/GetSettlementData" :readonly="false" :show-id="false">
            </elm-select-input>
          </el-form-item>
          <el-form-item>
          </el-form-item>
        </elm-row>
        <el-form-item label="附件">
          <elm-upload module_name="biz_bms_receipt_file" :rel_id="model.id" :multiple="true" :limit="10"  list-type="file" tip=""></elm-upload>
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input type="textarea" :rows="2" v-model="model.remark"></el-input>
        </el-form-item>
      </el-form>
      <el-card style="min-height: 140px;"  shadow="hover">
        <div slot="header">
          <span>付款单位信息</span>
        </div>
        <el-form ref="model" :model="model" size="small" label-width="80px">
          <elm-row>
            <el-form-item label="付款单位" prop="fk_unit">
              <el-input v-model="model.fk_unit"></el-input>
            </el-form-item>
            <el-form-item label="联系人" prop="fk_lxr">
              <el-input v-model="model.fk_lxr"></el-input>
            </el-form-item>
          </elm-row>
          <elm-row>
            <el-form-item label="电话" prop="fk_dh">
              <el-input v-model="model.fk_dh"></el-input>
            </el-form-item>
            <el-form-item label="邮箱" prop="fk_email">
              <el-input v-model="model.fk_email"></el-input>
            </el-form-item>
          </elm-row>
        </el-form>
      </el-card>
      <template #bottom>
        <el-button type="success" size="small" @click="submit">立即保存</el-button>
        <el-button size="small" @click="close">取消</el-button>
      </template>
    </elm-page-bb>
  </div>
</template>

<script>
export default {
  extends: elmVueBase,
  data() {
    return {
      model: {id: elm.newGuid()},
    }
  },
  async created() {
  },
  methods: {
    async submit() {
      await this.$refs["model"].validate();
      var res = await elm.post('/business/bms/receipt/Upsert', this.model);
      if (res == true) {
        this.v('保存成功。')
        this.close();
        this.request.callVue.tablebinding();
      }
      else {
        this.error('保存失败，请稍后尝试。');
      }
    },
  }
}
</script>